#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>

/*
typedef uint32_t in_addr_t;
struct in_addr
{
    in_addr_t s_addr;
};
struct sockaddr_in
{
    in_port_t sin_port;
    struct in_addr sin_addr;
};
*/

// in_addr转字符串
// int main()
// {
//     struct sockaddr_in addr1;
//     struct sockaddr_in addr2;
//     addr1.sin_addr.s_addr = 0;
//     addr2.sin_addr.s_addr = 0xffffffff;

//     char *ptr1 = inet_ntoa(addr1.sin_addr);
//     char *ptr2 = inet_ntoa(addr2.sin_addr);

//     printf("ptr1:%s, ptr2:%s\n", ptr1, ptr2);
//     return 0;
// }
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
void *Func1(void *p)
{
    struct sockaddr_in *addr = (struct sockaddr_in *)p;
    int count = 5;
    while (count--)
    {
        char *ptr = inet_ntoa(addr->sin_addr);
        printf("addr1: %s\n", ptr);
    }
    return NULL;
}
void *Func2(void *p)
{
    struct sockaddr_in *addr = (struct sockaddr_in *)p;
    int count = 5;

    while (count--)
    {
        char *ptr = inet_ntoa(addr->sin_addr);
        printf("addr2: %s\n", ptr);
    }
    return NULL;
}
int main()
{
    struct sockaddr_in addr1;
    struct sockaddr_in addr2;
    addr1.sin_addr.s_addr = 0;
    addr2.sin_addr.s_addr = 0xffffffff;

    pthread_t tid1 = 0;
    pthread_create(&tid1, NULL, Func1, &addr1);

    pthread_t tid2 = 0;
    pthread_create(&tid2, NULL, Func2, &addr2);

    pthread_join(tid1, NULL);
    pthread_join(tid2, NULL);
    return 0;
}